package co.fitstart.entity.market;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;
import com.demo2do.core.utils.DateFormatUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import co.fitstart.entity.user.User;

/**
 * 
 * @author cuteHU
 *
 */
@Entity
@Table(name = "market_leg_count")
@DynamicUpdate
@JsonIgnoreProperties(value = { "hibernate_lazy_initializer", "handler", "fieldHandler" })
public class MarketLegCount {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /** 姓名 */
    private String studentName;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @org.hibernate.annotations.Type(type = "date")
    private Date createTime;

    /** 练腿数 */
    private int legCount;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private User user;

    @Column(name = "is_disabled")
    private boolean disabled;

    /**
     * The default constructor
     */
    public MarketLegCount() {
    }

    /**
     * @return
     */
    public MarketLegCount disabled() {
        this.disabled = true;
        return this;
    }

    /**
     * @param legCount
     * @return
     */
    public MarketLegCount legCount(int legCount) {
        this.legCount = legCount;
        return this;
    }
    

    /**
     * @param studentName
     * @param legCount
     */
    public MarketLegCount(String studentName, int legCount, User user) {
        this.studentName = studentName;
        this.legCount = legCount;
        this.user = user;
        this.disabled = false;
        this.createTime = new Date();
    }
    
    /**
     * 
     * @return
     */
    public String getTimeString() {
        return DateFormatUtils.format(this.createTime, "yyyy-MM-dd");
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the studentName
     */
    public String getStudentName() {
        return studentName;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the legCount
     */
    public int getLegCount() {
        return legCount;
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param studentName the studentName to set
     */
    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param legCount the legCount to set
     */
    public void setLegCount(int legCount) {
        this.legCount = legCount;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
